<template>
  <div class="my">
    <div class="myinfo">
      <img @click="goLogin" :src="avator" alt="">
      <div @click="goLogin">
        <p>{{ userInfo.nickName }}</p>
        <p v-if="userInfo.nickName">微信用户</p>
        <p v-else>点击登录</p>
      </div>
    </div>
    <div class="iconlist">
      <div @click="goTo(item.url)" v-for="(item, index) in listData" :key="index">
        <span class="iconfont" :class="item.icon"></span>
        <span>{{ item.title }}</span>
      </div>
    </div>
  </div>
</template>

<script>
  import {toLogin, login} from "../../utils";

  export default {
    data() {
      return {
        avator: "http://yanxuan.nosdn.127.net/8945ae63d940cc42406c3f67019c5cb6.png",
        allcheck: false,
        Listids: [],
        userInfo: {},
        listData: [
          {
            title: "我的订单",
            icon: "icon-unie64a",
            url: "/pages/myorder/main"
          },
          {
            title: "优惠券",
            icon: "icon-youhuiquan",
            url: "/pages/coupon/main"
          },
          {
            title: "我的足迹",
            icon: "icon-zuji",
            url: "/pages/history/main"
          },
          {
            title: "我的收藏",
            icon: "icon-shoucang",
            url: "/pages/collectlist/main"
          },
          {
            title: "地址管理",
            icon: "icon-dizhiguanli",
            url: "/pages/address/main"
          },
          {
            title: "联系客服",
            icon: "icon-lianxikefu",
            url: "/pages/customer/main"
          },
          {
            title: "帮助中心",
            icon: "icon-bangzhuzhongxin",
            url: "/pages/help/main"
          },
          {
            title: "意见反馈",
            icon: "icon-yijianfankui",
            url: "/pages/feedback/main"
          }
        ]
      }
    },
    components: {},
    computed: {},
    created() {
    },
    mounted() {
    },
    methods: {
      goTo(url) {
        console.log(url);
        wx.showToast({
          title: url,
          icon: 'none',
          duration: 2000
        });
      },
      goLogin() {
        wx.navigateTo({
          url: "/pages/login/main"
        });
      }
    },
    onShow() {
      // 每次将要进入页面时都会调用
      if (login()) {
        this.userInfo = login();
        console.log(this.userInfo);
        this.avator = this.userInfo.avatarUrl;
      }
    }
  }

</script>

<style lang='scss' scoped>
  @import "./style.scss";
</style>

